/*
 * Copyright(c) 2018-2018, YuanYue Group, Inc. All rights reserved.
 *
 * This software is the confidential and proprietary information of YuanYue Group, Inc.
 * You shall not disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into with YuanYue Group.
 */
package net.wsfcp.android.ui.widget;

import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.widget.PopupWindow;
import android.widget.TextView;

import net.wsfcp.android.R;

/**
 * CameraAlbumPopwindow.java是全网覆盖平台的。
 * 相机相册选择弹窗
 * @author Shaoboyang
 * @version $Id: CameraAlbumPopwindow.java, v 0.1 2018-12-26 15:25 Shaoboyang Exp $$
 */
public class CameraAlbumPopwindow extends PopupWindow {
    Context mContext;
    private LayoutInflater mInflater;
    private View mContentView;

    TextView txt_camera;
    TextView txt_album;
    TextView txt_cancel;

    public CameraAlbumPopwindow(Context context, View.OnClickListener listener) {
        super(context);

        this.mContext = context;
        mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        mContentView = mInflater.inflate(R.layout.pop_camera_album, null);
        //设置View
        setContentView(mContentView);
        txt_camera = mContentView.findViewById(R.id.txt_camera);
        txt_album = mContentView.findViewById(R.id.txt_album);
        txt_cancel= mContentView.findViewById(R.id.txt_cancel);
        txt_camera.setOnClickListener(listener);
        txt_album.setOnClickListener(listener);
        txt_cancel.setOnClickListener(listener);

        //设置宽与高
        setWidth(WindowManager.LayoutParams.MATCH_PARENT);
        setHeight(WindowManager.LayoutParams.MATCH_PARENT);
        /**
         * 设置进出动画
         */
//        setAnimationStyle(R.style.MyPopupWindow);
        /**
         * 设置背景只有设置了这个才可以点击外边和BACK消失
         */
        setBackgroundDrawable(new ColorDrawable(0x22111111));

        /**
         * 设置可以获取集点
         */
        setFocusable(true);
        /**
         * 设置点击外边可以消失
         */
        setOutsideTouchable(true);
        /**
         *设置可以触摸
         */
        setTouchable(true);
        /**
         * 设置点击外部可以消失
         */
        setTouchInterceptor(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {

                /**
                 * 判断是不是点击了外部
                 */
                if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {
                    return true;
                }
                //不是点击外部
                return false;
            }
        });


        /**
         * 初始化View与监听器
         */
        initView();

        initListener();
    }


    private void initView() {

    }

    private void initListener() {

    }

}